<?php

namespace app\api\model;

use think\Model;

class GoodsModel extends Model
{
    protected $name="goods";

    public static function getOneGoods($goods_id)
    {
        $goods = self::where('id',$goods_id)->field('goods_name,goods_new_price,goods_old_price,img,overtime')->find()->toArray();
        $overtime = strtotime($goods['overtime'])-time();
        if ($overtime>0){
             $goods['order_price'] = $goods['goods_new_price'];
            $goods['goods_img'] = $goods['img'];

        }else{
            $goods['order_price'] = $goods['goods_old_price'];
            $goods['goods_img'] = $goods['img'];
        }
        return $goods;
    }
}
